<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>String三兄弟 | 后端学习记录</title><meta name="keywords" content="Java"><meta name="author" content="h0ss"><meta name="copyright" content="h0ss"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="一、String1、String概述String字符串使用“”来表示，属于对象。它是一个不可变的字符序列，所以每一次对String对象进行操作都会生成新的对象，对于频繁操作字符串来说效率低下，并且String类有以下几个特点：  1.String声明为final 不可被继承  2.String实现了Serializable接口：表明字符串支持序列化  3.String实现了Comparable接口">
<meta property="og:type" content="article">
<meta property="og:title" content="String三兄弟">
<meta property="og:url" content="https://blog.gpnusz.cn/2021/02/02/String%E4%B8%89%E5%85%84%E5%BC%9F/index.html">
<meta property="og:site_name" content="后端学习记录">
<meta property="og:description" content="一、String1、String概述String字符串使用“”来表示，属于对象。它是一个不可变的字符序列，所以每一次对String对象进行操作都会生成新的对象，对于频繁操作字符串来说效率低下，并且String类有以下几个特点：  1.String声明为final 不可被继承  2.String实现了Serializable接口：表明字符串支持序列化  3.String实现了Comparable接口">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://i.loli.net/2021/09/01/PRTlcsGZMQ7yBqn.jpg">
<meta property="article:published_time" content="2021-02-02T10:57:48.000Z">
<meta property="article:modified_time" content="2022-08-20T18:18:12.925Z">
<meta property="article:author" content="h0ss">
<meta property="article:tag" content="Java">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://i.loli.net/2021/09/01/PRTlcsGZMQ7yBqn.jpg"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://blog.gpnusz.cn/2021/02/02/String%E4%B8%89%E5%85%84%E5%BC%9F/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = { 
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: false,
  postUpdate: '2022-08-21 02:18:12'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    })(window)</script><meta name="generator" content="Hexo 5.4.0"><link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css"></head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="author-avatar"><img class="avatar-img" src="/img/avatar.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">51</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">14</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="not-top-img" id="page-header"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">后端学习记录</a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav></header><main class="layout" id="content-inner"><div id="post"><div id="post-info"><h1 class="post-title">String三兄弟</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-02-02T10:57:48.000Z" title="发表于 2021-02-02 18:57:48">2021-02-02</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-08-20T18:18:12.925Z" title="更新于 2022-08-21 02:18:12">2022-08-21</time></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">1.2k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>4分钟</span></span></div></div></div><article class="post-content" id="article-container"><h3 id="一、String"><a href="#一、String" class="headerlink" title="一、String"></a>一、String</h3><h4 id="1、String概述"><a href="#1、String概述" class="headerlink" title="1、String概述"></a>1、String概述</h4><p>String字符串使用“”来表示，属于对象。它是一个不可变的字符序列，所以每一次对String对象进行操作都会生成新的对象，对于频繁操作字符串来说效率低下，并且String类有以下几个特点：</p>
<ul>
<li><p>1.String声明为final 不可被继承</p>
</li>
<li><p>2.String实现了Serializable接口：表明字符串支持序列化</p>
</li>
<li><p>3.String实现了Comparable接口： 表明字符串可以比较大小</p>
</li>
<li><p>4.String内部定义了final byte[] value 可用于存储字符串数据</p>
</li>
</ul>
<h4 id="2、String与其他类型的转换"><a href="#2、String与其他类型的转换" class="headerlink" title="2、String与其他类型的转换"></a>2、String与其他类型的转换</h4><h5 id="1-String与基本数据类型、包装类之间的转换"><a href="#1-String与基本数据类型、包装类之间的转换" class="headerlink" title="1)String与基本数据类型、包装类之间的转换"></a>1)String与基本数据类型、包装类之间的转换</h5><p>   String –&gt; 基本数据类型/包装类   调用包装类的静态方法: parseXxx(str)<br>   基本数据类型/包装类 –&gt; String   调用String重载的valueOf(xx)方法</p>
<h5 id="2-String与char-之间的相互转换"><a href="#2-String与char-之间的相互转换" class="headerlink" title="2)String与char[]之间的相互转换"></a>2)String与char[]之间的相互转换</h5><p>   String –&gt; char[]  调用String的toCharArray方法<br>   char[] –&gt; String  直接调用String的构造器</p>
<h5 id="3-String与byte-之间的相互转换"><a href="#3-String与byte-之间的相互转换" class="headerlink" title="3)String与byte[]之间的相互转换"></a>3)String与byte[]之间的相互转换</h5><p>   String –&gt; byte[]  调用String的getBytes方法<br>   byte[] –&gt; String  直接调用String的构造器</p>
<h4 id="3、String的常用方法"><a href="#3、String的常用方法" class="headerlink" title="3、String的常用方法"></a>3、String的常用方法</h4><p>1)length():返回字符串长度<br>2)charAt(index):返回索引index处的字符<br>3)isEmpty():判断字符串是否为空<br>4)toLowerCase():将字符串全部转换为小写字符<br>5)toUpperCase():将字符串全部转换为大写字符<br>6)trim():返回字符串的副本，忽略前后的空格<br>7)equals(obj):比较字符串内容是否相等<br>8)equalsIgnoreCase(obj):比较字符串内容是否相等忽略大小写<br>9)concat(str):连接两个字符串<br>10)compareTo(anotherString):比较两个字符串<br>11)substring(begin,[end]):返回一个新的字符串子串</p>
<h4 id="4、直接赋值与new的区别以及拼接问题"><a href="#4、直接赋值与new的区别以及拼接问题" class="headerlink" title="4、直接赋值与new的区别以及拼接问题"></a>4、直接赋值与new的区别以及拼接问题</h4><p>直接定义的String指向常量池，而new的指向堆。在java中，用new关键字创建对象会在堆中创建。</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 这个操作会先在常量池中查找是否存在&quot;abc&quot;,如果不存在则新建一个，然后在堆中创建一份拷贝对象，把堆中的地址赋给s1</span></span><br><span class="line">String s1 = <span class="keyword">new</span> String(<span class="string">&quot;abc&quot;</span>); </span><br><span class="line">String s2 = <span class="string">&quot;abc&quot;</span>;</span><br><span class="line"><span class="comment">//如上解释在这种定义方式下 s1和s2在内存中不是同一块空间 ==比较的是地址值</span></span><br><span class="line">System.out.println(s1==s2); <span class="comment">// false</span></span><br></pre></td></tr></table></figure>

<p>String对象在拼接字符串时，每次进行拼接都会开辟新的空间，产生新的对象，关于String的拼接有以下几个特点：</p>
<ul>
<li>1.常量与常量的拼接结果是在常量池中的，并且相同的值有且只有一个</li>
<li>2.只要拼接有一方为变量，那么结果就是在堆空间中</li>
<li>3.当调用 intern 方法时，如果池已经包含一个等于此 String 对象的字符串 ，则返回池中的字符串。否则，将此 String 对象添加到池中，并返回此 String 对象的引用</li>
</ul>
<h3 id="二、StringBuffer和StringBuilder"><a href="#二、StringBuffer和StringBuilder" class="headerlink" title="二、StringBuffer和StringBuilder"></a>二、StringBuffer和StringBuilder</h3><h4 id="1-概述"><a href="#1-概述" class="headerlink" title="1.概述"></a>1.概述</h4><p>String是不可变的字符序列，相反StringBuffer、StringBuilder是可变的字符序列，对于它们来说是可以重新赋值的，并且不会产生新的对象。</p>
<p>StringBuilder是线程不安全的，但效率会较高。StringBuffer是线程安全的，如果需要同步操作时必须使用它，但由于线程安全(synchronized方法)因而导致它的效率会较StringBuilder低。</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">String str1 = <span class="keyword">new</span> String();<span class="comment">// byte[] value</span></span><br><span class="line">String str1 = <span class="keyword">new</span> String(“abc”); <span class="comment">// new byte[] = &#123;97,98,99&#125;</span></span><br><span class="line"></span><br><span class="line"><span class="comment">//调用StringBuffer空参构造器时，底层创建了一个长度为16的byte型数组</span></span><br><span class="line">StringBuffer strBuf = <span class="keyword">new</span> StringBuffer(); <span class="comment">// byte[16] value </span></span><br><span class="line">System.out.println(strBuf.length()); <span class="comment">// 有效长度仍为0</span></span><br><span class="line"></span><br><span class="line"><span class="comment">//调用string为参的构造器，底层创建了一个长度为字符串长度+16的byte型数组</span></span><br><span class="line"><span class="comment">//super(str.length() + 16);</span></span><br><span class="line">StringBuffer strBuf = <span class="keyword">new</span> StringBuffer(<span class="string">&quot;abc&quot;</span>); </span><br></pre></td></tr></table></figure>

<h4 id="2-扩容"><a href="#2-扩容" class="headerlink" title="2.扩容"></a>2.扩容</h4><p>若原容量为n，默认扩容2n+2，同时将原有数组元素复制到新数组中；如果扩容后仍不够，将添加String后的长度为数组长度。因此开发中建议使用指定容量的构造器 以免频繁扩容造成性能损耗。</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">int</span> oldCapacity = value.length &gt;&gt; coder;</span><br><span class="line"><span class="keyword">int</span> newCapacity = (oldCapacity &lt;&lt; <span class="number">1</span>) + <span class="number">2</span>;</span><br><span class="line"><span class="keyword">if</span> (newCapacity - minCapacity &lt; <span class="number">0</span>) &#123;</span><br><span class="line">    newCapacity = minCapacity;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="3-常用方法"><a href="#3-常用方法" class="headerlink" title="3.常用方法"></a>3.常用方法</h4><p>append(T content):添加操作<br>delete(start,end):从[start,end)进行删除操作<br>replace(start,end,String content): 对[start,end)的数据替换为content<br>insert(offset,xxx):在offset位置插入xxx<br>reverse():反转StringBuffer<br>indexOf(str):返回str的索引</p>
<h3 id="三、效率对比"><a href="#三、效率对比" class="headerlink" title="三、效率对比"></a>三、效率对比</h3><p>StringBuilder&gt;StringBuffer&gt;String</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 简陋的测试</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">StringBufferBuilderTest2</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">long</span> startTime = <span class="number">0</span>;</span><br><span class="line">        <span class="keyword">long</span> endTime = <span class="number">0</span>;</span><br><span class="line">        String str1 = <span class="string">&quot;&quot;</span>;</span><br><span class="line">        StringBuffer strBuf = <span class="keyword">new</span> StringBuffer(<span class="string">&quot;&quot;</span>);</span><br><span class="line">        StringBuilder strBuilder = <span class="keyword">new</span> StringBuilder(<span class="string">&quot;&quot;</span>);</span><br><span class="line">        startTime = System.currentTimeMillis();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> i=<span class="number">0</span>;i&lt;<span class="number">200000</span>;i++)&#123;</span><br><span class="line">            str1 = str1 + i;</span><br><span class="line">        &#125;</span><br><span class="line">        endTime = System.currentTimeMillis();</span><br><span class="line">        System.out.printf(<span class="string">&quot;String: %d ms\n&quot;</span>,endTime-startTime);</span><br><span class="line"></span><br><span class="line">        startTime = System.currentTimeMillis();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> i=<span class="number">0</span>;i&lt;<span class="number">200000</span>;i++)&#123;</span><br><span class="line">            strBuf.append(String.valueOf(i));</span><br><span class="line">        &#125;</span><br><span class="line">        endTime = System.currentTimeMillis();</span><br><span class="line">        System.out.printf(<span class="string">&quot;StringBuffer: %d ms\n&quot;</span>,endTime-startTime);</span><br><span class="line">        startTime = System.currentTimeMillis();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> i=<span class="number">0</span>;i&lt;<span class="number">200000</span>;i++)&#123;</span><br><span class="line">            strBuilder.append(String.valueOf(i));</span><br><span class="line">        &#125;</span><br><span class="line">        endTime = System.currentTimeMillis();</span><br><span class="line">        System.out.printf(<span class="string">&quot;StringBuilder: %d ms\n&quot;</span>,endTime-startTime);</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>output：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">String: 20727 ms</span><br><span class="line">StringBuffer: 13 ms</span><br><span class="line">StringBuilder: 7 ms</span><br></pre></td></tr></table></figure>

</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">h0ss</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://blog.gpnusz.cn/2021/02/02/String%E4%B8%89%E5%85%84%E5%BC%9F/">https://blog.gpnusz.cn/2021/02/02/String%E4%B8%89%E5%85%84%E5%BC%9F/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://blog.gpnusz.cn" target="_blank">后端学习记录</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/Java/">Java</a></div><div class="post_share"></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2021/02/02/%E8%AE%A1%E7%BD%91%E8%AF%BE%E7%A8%8B%E5%A4%8D%E4%B9%A0/"><img class="prev-cover" src="https://i.loli.net/2021/09/01/PvqRnTrUBh1a37J.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">计网课程复习</div></div></a></div><div class="next-post pull-right"><a href="/2021/02/02/JAVA%E5%BC%82%E5%B8%B8%E5%A4%84%E7%90%86/"><img class="next-cover" src="https://tse2-mm.cn.bing.net/th/id/OIP.anGjOGF_UjPBdekSgF-wnQAAAA?pid=ImgDet&amp;rs=1" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">JAVA异常处理</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span> 相关推荐</span></div><div class="relatedPosts-list"><div><a href="/2022/11/16/给开源项目提了个PR/" title="给开源项目提了个PR"><img class="cover" src="https://i.loli.net/2021/09/01/PRTlcsGZMQ7yBqn.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-11-16</div><div class="title">给开源项目提了个PR</div></div></a></div><div><a href="/2022/08/21/【Debug】bitField-引发的栈溢出排错记/" title="【Debug】bitField 引发的栈溢出排错记"><img class="cover" src="https://i.loli.net/2021/09/01/PRTlcsGZMQ7yBqn.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-08-21</div><div class="title">【Debug】bitField 引发的栈溢出排错记</div></div></a></div><div><a href="/2022/07/16/【RPC】详解SPI机制/" title="【RPC】详解SPI机制"><img class="cover" src="https://i.loli.net/2021/09/01/PvqRnTrUBh1a37J.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-07-16</div><div class="title">【RPC】详解SPI机制</div></div></a></div><div><a href="/2022/07/10/【RPC】基本网络通信模型/" title="【RPC】基本网络通信模型"><img class="cover" src="https://i.loli.net/2021/09/01/PvqRnTrUBh1a37J.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-07-10</div><div class="title">【RPC】基本网络通信模型</div></div></a></div><div><a href="/2022/07/02/【JVM】类加载全过程简记/" title="【JVM】类加载全过程简记"><img class="cover" src="https://i.loli.net/2021/09/01/PRTlcsGZMQ7yBqn.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-07-02</div><div class="title">【JVM】类加载全过程简记</div></div></a></div><div><a href="/2022/06/28/【RPC】RPC实战与核心的学习笔记/" title="【RPC】RPC实战与核心的学习笔记"><img class="cover" src="https://i.loli.net/2021/09/01/PvqRnTrUBh1a37J.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-06-28</div><div class="title">【RPC】RPC实战与核心的学习笔记</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="card-info-avatar is-center"><img class="avatar-img" src="/img/avatar.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/><div class="author-info__name">h0ss</div><div class="author-info__description">一个苦逼后端仔的学习记录</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">51</div></a></div><div class="card-info-data-item is-center"><a href="/tags/"><div class="headline">标签</div><div class="length-num">14</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://gitee.com/h0ss"><i class="fab fa-github"></i><span>Gitee仓库</span></a></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">Java后端技术栈语雀文档：https://www.yuque.com/oliver-wdtb1/java</div></div><div class="sticky_layout"><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2022/11/16/%E7%BB%99%E5%BC%80%E6%BA%90%E9%A1%B9%E7%9B%AE%E6%8F%90%E4%BA%86%E4%B8%AAPR/" title="给开源项目提了个PR">给开源项目提了个PR</a><time datetime="2022-11-15T17:28:40.000Z" title="发表于 2022-11-16 01:28:40">2022-11-16</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2022/09/03/%E3%80%90MySQL%E3%80%91InnoDB%E7%9A%84%E8%A1%8C%E6%A0%BC%E5%BC%8F/" title="【MySQL】InnoDB的行格式">【MySQL】InnoDB的行格式</a><time datetime="2022-09-02T18:17:38.000Z" title="发表于 2022-09-03 02:17:38">2022-09-03</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2022/08/21/%E3%80%90Debug%E3%80%91bitField-%E5%BC%95%E5%8F%91%E7%9A%84%E6%A0%88%E6%BA%A2%E5%87%BA%E6%8E%92%E9%94%99%E8%AE%B0/" title="【Debug】bitField 引发的栈溢出排错记">【Debug】bitField 引发的栈溢出排错记</a><time datetime="2022-08-20T18:10:40.000Z" title="发表于 2022-08-21 02:10:40">2022-08-21</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2022/07/16/%E3%80%90RPC%E3%80%91%E8%AF%A6%E8%A7%A3SPI%E6%9C%BA%E5%88%B6/" title="【RPC】详解SPI机制">【RPC】详解SPI机制</a><time datetime="2022-07-15T18:51:57.000Z" title="发表于 2022-07-16 02:51:57">2022-07-16</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2022/07/14/%E3%80%90Redis%E3%80%91%E9%87%8D%E8%A6%81%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E5%9F%BA%E7%A1%80/" title="【Redis】重要数据结构基础">【Redis】重要数据结构基础</a><time datetime="2022-07-13T17:22:08.000Z" title="发表于 2022-07-14 01:22:08">2022-07-14</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><div class="js-pjax"></div><script defer="defer" id="fluttering_ribbon" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-fluttering-ribbon.min.js"></script><script id="canvas_nest" defer="defer" color="0,0,255" opacity="0.7" zIndex="-1" count="99" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-nest.min.js"></script><script id="click-heart" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/click-heart.min.js" async="async" mobile="false"></script><script id="click-show-text" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/click-show-text.min.js" data-mobile="false" data-text="爱国,敬业,诚信,友善,自由,平等,公正,法治,富强,民主,文明,和谐" data-fontsize="16px" data-random="false" async="async"></script></div></body></html>